package com.milhouz.pokertimer.model;

import java.util.Iterator;
import java.util.LinkedList;

public class BlindList implements Iterable<Blind> {

	public final LinkedList<Blind> blinds = new LinkedList<Blind>(); 
	
	public void add(Blind b) {
		blinds.add(b);
	}
	
	public void add(int round, int time, double smallBlind) {
		blinds.add(new Blind(round, time, smallBlind));
	}
	
	public void add(int round, int time, double smallBlind, double antes, boolean hasBreak) {
		blinds.add(new Blind(round, time, smallBlind, antes, hasBreak));
	}
	
	/**
	 * Return the blind corresponding to the round number
	 * @param roundNumber Round number
	 * @return the blind
	 */
	public Blind getBlindByRound(int roundNumber) {
		for (Blind curBlind : blinds) {
			if (curBlind.getRound() == roundNumber) {
				return curBlind;
			}
		}
		return null;
	}
	
	public void setBreak(int nbBlind) {
		blinds.get(nbBlind).setHasBreak(true);
	}
		
	public Iterator<Blind> iterator() {
		return this.blinds.iterator();
	}

	public LinkedList<Blind> getBlinds() {
		return blinds;
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		if (blinds != null && !blinds.isEmpty()) {
			for (Blind blinds : this.blinds) {
				sb.append(blinds);
			}
		} else {
			sb.append("No blinds.");
		}
		return sb.toString();
	}

}
